package Group.projectA;

import java.io.BufferedWriter;
import java.io.IOException;

public class Person {
	private String name;
	private String sex;
	private String address;
	private String phoneNum;
	private String email;
	/**
	 * 构造方法-》构造新的联系人
	 * @param name
	 * @param sex
	 * @param address
	 * @param phoneNum
	 * @param email
	 */
	public Person(String name, String sex, String address, String phoneNum,
			String email) {
		super();
		this.name = name;
		this.sex = sex;
		this.address = address;
		this.phoneNum = phoneNum;
		this.email = email;
	}
	/**
	 * 获取、设置联系人信息
	 * @return
	 */
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getPhoneNum() {
		return phoneNum;
	}
	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
	public void saveMe(BufferedWriter out){
		/**
		 * 指定输出对象
		 */
		try{
			/**
			 * 保存联系人
			 */
			out.write(this.name+" "+this.sex+" "+this.phoneNum+" "+this.address+" "+this.email);
		}catch (IOException e) {
			System.out.println("保存联系人时发生异常！");
		    e.printStackTrace();
		}
	}
	
	public Person getUpdatePerson(){
		/**
		 * 修改联系人部分信息，生成一个新的对象
		 */
		return new Person(this.name,this.sex,this.phoneNum,this.address,this.email);
	}
	

}
